package com.cgbl.service.view

import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.widget.LinearLayout
import android.widget.TextView
import com.cgbl.service.R

class GLTagTextView(context: Context?, attrs: AttributeSet?) : LinearLayout(context, attrs) {

    private var mTitleTv: TextView? = null

    init {
        init()
        resolveAttrs(context, attrs)
    }


    fun init() {
        val view: View = View.inflate(context, R.layout.app_view_tag_text, this)
        mTitleTv = view.findViewById(R.id.tv_title)
    }

    private fun resolveAttrs(context: Context?, attrs: AttributeSet?) {
        val typedArray = context?.obtainStyledAttributes(attrs, R.styleable.TagTextView);
        val title = typedArray?.getString(R.styleable.TagTextView_title)
        typedArray?.recycle();
        setTitle(title ?: "");
    }

    private fun setTitle(title: String) {
        mTitleTv?.text = title
    }

}